package seqlist.link.leetcode;

/**
 * @author yuisama
 * @date 2023/03/19 15:08
 * 带环链表的判定
 **/
public class Num141_ListHasCycle {
    // 快慢指针
    public boolean hasCycle(ListNode head) {
        ListNode low = head,fast = head;
        while (fast != null && fast.next != null) {
            low = low.next;
            fast = fast.next.next;
            if (low == fast) {
                return true;
            }
        }
        return false;
    }
}